// This example shows how to read value of a single node, and display it. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. using System; using OpcLabs.EasyOpc.UA; using OpcLabs.EasyOpc.UA.OperationModel; namespace UADocExamples._EasyUAClient { partial class ReadValue { public static void Overload1() { UAEndpointDescriptor endpointDescriptor = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"; // or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported) // or "https://opcua.demo-this.com:51212/UA/SampleServer/" // Instantiate the client object. var client = new EasyUAClient(); Console.WriteLine("Obtaining value of a node..."); object value; try { value = client.ReadValue(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10853"); } catch (UAException uaException) { Console.WriteLine($"*** Failure: {uaException.GetBaseException().Message}"); return; } // Display results Console.WriteLine($"value: {value}"); } } }
# This example shows how to read value of a single node, and display it. # # Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . # OPC client and subscriber examples in PowerShell on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-PowerShell . # Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own # a commercial license in order to use Online Forums, and we reply to every post. #requires -Version 5.1 using namespace OpcLabs.EasyOpc.UA using namespace OpcLabs.EasyOpc.UA.OperationModel # The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows . Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcUA.dll" Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcUAComponents.dll" [UAEndpointDescriptor]$endpointDescriptor = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer" # or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported) # or "https://opcua.demo-this.com:51212/UA/SampleServer/" # Instantiate the client object. $client = New-Object EasyUAClient Write-Host "Obtaining value of a node..." try { $value = $client.ReadValue($endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10853") } catch [UAException] { Write-Host "*** Failure: $($PSItem.Exception.GetBaseException().Message)" return } # Display results Write-Host "value: $($value)"
' This example shows how to read value of a single node, and display it. ' ' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . ' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET . ' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own ' a commercial license in order to use Online Forums, and we reply to every post. Imports OpcLabs.EasyOpc.UA Imports OpcLabs.EasyOpc.UA.OperationModel Namespace _EasyUAClient Partial Friend Class ReadValue Public Shared Sub Overload1() ' Define which server we will work with. Dim endpointDescriptor As UAEndpointDescriptor = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer" ' or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported) ' or "https://opcua.demo-this.com:51212/UA/SampleServer/" ' Instantiate the client object Dim client = New EasyUAClient() ' Obtain value of a node Dim value As Object Try value = client.ReadValue(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10853") Catch uaException As UAException Console.WriteLine("*** Failure: {0}", uaException.GetBaseException.Message) Exit Sub End Try ' Display results Console.WriteLine("value: {0}", value) End Sub End Class End Namespace
// This example shows how to read value of a single node, and display it. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. #include "stdafx.h" // Includes "QuickOpc.h", and other commonly used files #include "ReadValue.h" namespace _EasyUAClient { void ReadValue::Main() { // Initialize the COM library CoInitializeEx(NULL, COINIT_MULTITHREADED); { // Instantiate the client object _EasyUAClientPtr ClientPtr(__uuidof(EasyUAClient)); // Perform the operation _variant_t value = ClientPtr->ReadValue( //L"http://opcua.demo-this.com:51211/UA/SampleServer", L"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer", L"nsu=http://test.org/UA/Data/ ;i=10853"); // Display results _variant_t vString; vString.ChangeType(VT_BSTR, &value); _tprintf(_T("value: %s\n"), (LPCTSTR)CW2CT((_bstr_t)vString)); } // Release all interface pointers BEFORE calling CoUninitialize() CoUninitialize(); } }
// This example shows how to read value of a single node, and display it. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. var Client = new ActiveXObject("OpcLabs.EasyOpc.UA.EasyUAClient"); var value = Client.ReadValue( //"http://opcua.demo-this.com:51211/UA/SampleServer", "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer", "nsu=http://test.org/UA/Data/ ;i=10853"); WScript.Echo("value: " + value);
// This example shows how to read value of a single node, and display it. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. class procedure ReadValue.Main; var Client: EasyUAClient; Value: OleVariant; begin // Instantiate the client object Client := CoEasyUAClient.Create; Value := Client.ReadValue( //'http://opcua.demo-this.com:51211/UA/SampleServer', 'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer', 'nsu=http://test.org/UA/Data/ ;i=10853'); WriteLn('value: ', Value); end;
// This example shows how to read value of a single node, and display it. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // OPC client and subscriber examples in Object Pascal (Delphi) on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-OP . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. class procedure ReadValue.Main; var Client: OpcLabs_EasyOpcUA_TLB._EasyUAClient; Value: OleVariant; begin // Instantiate the client object Client := CoEasyUAClient.Create; // Obtain value of a node try Value := Client.ReadValue( //'http://opcua.demo-this.com:51211/UA/SampleServer', //'https://opcua.demo-this.com:51212/UA/SampleServer/', 'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer', 'nsu=http://test.org/UA/Data/ ;i=10853'); except on E: EOleException do begin WriteLn(Format('*** Failure: %s', [E.GetBaseException.Message])); Exit; end; end; // Display results WriteLn('value: ', Value); end;
// This example shows how to read value of a single node, and display it. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // OPC client and subscriber examples in PHP on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-PHP . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. // Instantiate the client object $Client = new COM("OpcLabs.EasyOpc.UA.EasyUAClient"); // Perform the operation try { $value = $Client->ReadValue( //"http://opcua.demo-this.com:51211/UA/SampleServer", "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer", "nsu=http://test.org/UA/Data/ ;i=10853"); } catch (com_exception $e) { printf("*** Failure: %s\n", $e->getMessage()); Exit(); } // Display results printf("Value: %s\n", $value);
// This example shows how to read value of a single node, and display it. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . mle_outputtext.Text = "" // Instantiate the client object OLEObject client client = CREATE OLEObject client.ConnectToNewObject("OpcLabs.EasyOpc.UA.EasyUAClient") // Obtain value of a node mle_outputtext.Text = mle_outputtext.Text + "Reading node value..." + "~r~n" Any value TRY value = client.ReadValue("http://opcua.demo-this.com:51211/UA/SampleServer", "nsu=http://test.org/UA/Data/ ;i=10853") CATCH (OLERuntimeError oleRuntimeError) mle_outputtext.Text = mle_outputtext.Text + "*** Failure: " + oleRuntimeError.Description + "~r~n" RETURN END TRY // Display results mle_outputtext.Text = mle_outputtext.Text + String(value) + "~r~n"
# This example shows how to read value of a single node, and display it. # # The Python for Windows (pywin32) extensions package is needed. Install it using "pip install pypiwin32". # CAUTION: We now recommend using Python.NET package instead. Full set of examples with Python.NET is available! # # Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . import win32com.client from pywintypes import com_error # Instantiate the client object client = win32com.client.Dispatch('OpcLabs.EasyOpc.UA.EasyUAClient') # Perform the operation try: value = client.ReadValue('opc.tcp://opcua.demo-this.com:51210/UA/SampleServer', 'nsu=http://test.org/UA/Data/ ;i=10853') except com_error as e: print('*** Failure: ' + e.args[2][1] + ': ' + e.args[2][2]) exit() # Display results print('value: ', value)
REM This example shows how to read value of a single node, and display it. REM REM Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . REM OPC client and subscriber examples in Visual Basic on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VB . REM Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own REM a commercial license in order to use Online Forums, and we reply to every post. Public Sub ReadValue_Main_Command_Click() OutputText = "" ' Instantiate the client object Dim Client As New EasyUAClient ' Perform the operation On Error Resume Next Dim value As Variant value = Client.ReadValue("opc.tcp://opcua.demo-this.com:51210/UA/SampleServer", "nsu=http://test.org/UA/Data/ ;i=10853") If Err.Number <> 0 Then OutputText = OutputText & "*** Failure: " & Err.Source & ": " & Err.Description & vbCrLf Exit Sub End If On Error GoTo 0 ' Display results OutputText = OutputText & "value: " & value & vbCrLf End Sub
Rem This example shows how to read value of a single node, and display it. Rem Rem Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBScript . Rem Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own Rem a commercial license in order to use Online Forums, and we reply to every post. Option Explicit ' Instantiate the client object Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.UA.EasyUAClient") ' Perform the operation On Error Resume Next Dim value: value = Client.ReadValue("opc.tcp://opcua.demo-this.com:51210/UA/SampleServer", "nsu=http://test.org/UA/Data/ ;i=10853") If Err.Number <> 0 Then WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description WScript.Quit End If On Error Goto 0 ' Display results WScript.Echo "value: " & value
# This example shows how to read value of a single node, and display it. # # Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . # OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python . # Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own # a commercial license in order to use Online Forums, and we reply to every post. # The QuickOPC package is needed. Install it using "pip install opclabs_quickopc". import opclabs_quickopc # Import .NET namespaces. from OpcLabs.EasyOpc.UA import * from OpcLabs.EasyOpc.UA.OperationModel import * endpointDescriptor = UAEndpointDescriptor('opc.tcp://opcua.demo-this.com:51210/UA/SampleServer') # or 'http://opcua.demo-this.com:51211/UA/SampleServer' (currently not supported) # or 'https://opcua.demo-this.com:51212/UA/SampleServer/' # Instantiate the client object. client = EasyUAClient() # Perform the operation. try: value = IEasyUAClientExtension.ReadValue(client, endpointDescriptor, UANodeDescriptor('nsu=http://test.org/UA/Data/ ;i=10853')) except UAException as uaException: print('*** Failure: ' + uaException.GetBaseException().Message) exit() # Display results. print('value: ', value, sep='') print('Finished.')
// This example shows how to repeatedly read value of a single node, and display it. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. using System; using System.Threading; using OpcLabs.EasyOpc.UA; using OpcLabs.EasyOpc.UA.OperationModel; namespace UADocExamples._EasyUAClient { partial class ReadValue { public static void Repeated() { const string endpointDescriptorUrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"; // or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported) // or "https://opcua.demo-this.com:51212/UA/SampleServer/" const string nodeIdExpandedText = "nsu=http://test.org/UA/Data/ ;i=10221"; // Example settings with Softing dataFEED OPC Suite: // endpointDescriptorUrlString = "opc.tcp://localhost:4980/Softing_dataFEED_OPC_Suite_Configuration1"; // nodeIdExpandedText = "nsu=Local%20Items ;s=Local Items.EAK_Test1.EAK_Testwert1_I4"; // Instantiate the client object. var client = new EasyUAClient(); for (int i = 1; i <= 60; i++) { Console.Write($"@{DateTime.Now}: "); // Obtain value of a node object value; try { value = client.ReadValue(endpointDescriptorUrlString, nodeIdExpandedText); } catch (UAException uaException) { Console.WriteLine($"*** Failure: {uaException.GetBaseException().Message}"); return; } // Display results Console.WriteLine($"Read {value}"); // Thread.Sleep(1000); } } } }
// This example shows how to repeatedly read value of a single node, and display it. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // OPC client and subscriber examples in Object Pascal (Delphi) on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-OP . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. class procedure ReadValue.Repeated; const EndpointDescriptorUrlString = //'http://opcua.demo-this.com:51211/UA/SampleServer'; //'https://opcua.demo-this.com:51212/UA/SampleServer/'; 'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer'; NodeIdExpandedText = 'nsu=http://test.org/UA/Data/ ;i=10221'; // Example settings with Softing dataFEED OPC Suite: // EndpointDescriptorUrlString = 'opc.tcp://localhost:4980/Softing_dataFEED_OPC_Suite_Configuration1'; // NodeIdExpandedText = 'nsu=Local%20Items ;s=Local Items.EAK_Test1.EAK_Testwert1_I4'; var Client: OpcLabs_EasyOpcUA_TLB._EasyUAClient; Value: OleVariant; I: Integer; begin // Instantiate the client object Client := CoEasyUAClient.Create; for I := 1 to 60 do begin Write('@', TimeToStr(Now), ': '); // Obtain value of a node try Value := Client.ReadValue(EndpointDescriptorUrlString, NodeIdExpandedText); except on E: EOleException do WriteLn(Format('*** Failure: %s', [E.GetBaseException.Message])); end; // Display results WriteLn('Read ', Value); // Sleep(1000); end; end;
Copyright © 2004-2024 CODE Consulting and Development, s.r.o., Plzen. All rights reserved.
Documentation Home, Send Documentation Feedback. Technical Support